﻿{include title="菜单管理" keywords="" description=""  file='../application/admin/view/layout/header.html' /}
<body>
<div class="x-nav">
	<span class="layui-breadcrumb">
		<a>
		  <cite>首页</cite>
		</a>
		<a>
		  <cite>管理员管理</cite>
		</a>
		<a>
		  <cite>菜单管理</cite>
		</a>
	</span>
	<a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新">
		<i class="layui-icon" style="line-height:30px">&#xe669;</i>
	</a>
</div>
<div class="x-body">
	<xblock>
		<button class="layui-btn" onclick="x_admin_show('添加菜单节点','{:url(\'/admin/admin_menu/menuAdd\')}',600,600)"><i class="layui-icon"></i>添加</button>
	</xblock>
	<table class="layui-table">
		<thead>
		<tr>
			<th width="25">排序</th>
			<th width="40">ID</th>
			<th width="100">菜单图标</th>
			<th width="200">菜单名称</th>
			<th width="200">URL路径</th>
			<th width="200">是否显示</th>
			<th width="200">菜单状态</th>
			<th width="100">操作</th>
		</thead>
		<tbody>
		<form action="" class="form">
			{foreach $data as $k => $v}
			<tr class="text-c">
				<td><input class="layui-input" name="{$v['id']}" value="{$v['order']}" style="width:60px;text-align: center;padding-left:0px;" type="text"></td>
				<td>{$v['id']}</td>
				<td><i class="layui-icon {$v['logo']}"></i></td>
				<td style="text-align: left;">{:str_repeat('　　',$v['level']).'|--'.$v['name']}</td>
				<td>{$v['url']}</td>
				<td>
					{if ($v['type']==0)}
					<span class="layui-btn layui-btn-xs layui-btn-disabled">否</span>
					{else}
					<span class="layui-btn layui-btn-xs layui-btn-normal">是</span>
					{/if}
				</td>
				<td>
					{if ($v['status']==0)}
					<span class="layui-btn layui-btn-xs layui-btn-disabled">禁用</span>
					{else}
					<span class="layui-btn layui-btn-xs layui-btn-normal">正常</span>
					{/if}
				</td>
				<td>
					<a title="添加" href="javascript:;" onclick="admin_permission_add('添加菜单节点','{:url(\'/admin/admin_menu/menuAdd\',[\'menu_id\'=>$v[\'id\']])}',600,600)" class="ml-5" style="text-decoration:none">
						<i class="layui-icon">&#xe654;</i>
					</a>
					<a title="编辑" href="javascript:;" onclick="admin_permission_edit('菜单编辑','{:url(\'admin/admin_menu/menuedit\',[\'id\'=>$v[\'id\']])}',600,600)" class="ml-5" style="text-decoration:none">
						<i class="layui-icon">&#xe642;</i>
					</a>
					<a title="删除" href="javascript:;" onclick="admin_permission_del(this,'{$v[\'id\']}')" class="ml-5" style="text-decoration:none">
						<i class="layui-icon">&#xe640;</i>
					</a>
				</td>
			</tr>
			{/foreach}
		</form>
		</tbody>
	</table>
	<div class="layui-btn layui-btn-normal set_sort"> 排序 </div>
</div>
<script>
    //排序
    $(".set_sort").on('click',function () {
        $.post('<?php echo url("admin/admin_menu/menuOrder"); ?>',{order_str:$(".form").serialize()},function (msg) {
            if (msg.status =='y'){
                layer.msg(msg.info,{icon:1,time:1000});
                setTimeout(function () {
                    location.reload();
                },1000)
            }else{
                layer.msg(msg.info,{icon:1,time:1000});
            }
        });
    })
</script>

<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript">

    /*管理员-菜单-添加*/
    function admin_permission_add(title,url,w,h){
        x_admin_show(title,url,w,h);
    }
    /*管理员-菜单-编辑*/
    function admin_permission_edit(title,url,w,h){
        x_admin_show(title,url,w,h);
    }

    /*管理员-菜单-删除*/
    function admin_permission_del(obj,id){
        layer.confirm('确认要删除吗？',function(index){
            $.ajax({
                type: 'POST',
                url: '<?php echo url("admin/admin_menu/menuDel"); ?>'+'?id='+id,
                dataType: 'json',
                success: function(data){
                    if (data.status=='y'){
                        $(obj).parents("tr").remove();
                        layer.msg(data.info,{icon:1,time:1000});
                    }else{
                        layer.msg(data.info,{icon:2,time:1000});
                    }

                }
            });
        });
    }
</script>
</body>
</html>